require('./curriculum.less')
require('../../assets/fonts/iconfont.css')

//引入顶部导航
const navTop = require('../../utils/nav-top')
navTop.showNavTop('curriculum');

//引入底部导航
const nav = require('../../utils/nav')
nav.showNav('sports');

// 引入文档加载事件，dom选择器封装
let { $, $$, $$$ } = require('../../utils/dom')
//引入axios
const axios = require('../../utils/axios')

// $(function(){
/**
 * 获取课程请求列表详情
 */
 axios.get('/api/train/courseList').then(function (res) {
  if (res.data.errno === 0) {
    // 渲染最新课程
    res.data.data.forEach(function (v, i) {
      // console.log(i);
      if (i == 0) {
        $$("#newJump").href = "./couseDetail.html#"+v.courseId
        $$("#lessonImgNew").src = `http://47.96.154.185:3701${v.imgurl}`
        $$("#lessonTitle").textContent = v.name
        $$("#lessonDital").textContent = v.desc
      } else {
        // 动态渲染课程
        let div = document.createElement("a")
        div.href = `./couseDetail.html#${v.courseId}`
        div.classList.add("lesson_box")
        let p1 = document.createElement("p")
        let p2 = document.createElement("p")
        div.style.background = `url(http://47.96.154.185:3701${v.imgurl})`
        p1.textContent = v.name
        p2.textContent = v.desc
        div.classList.add("lesson_list")
        p1.classList.add("lesson_title")
        p2.classList.add("lesson_dital")
        div.append(p1)
        div.append(p2)
        $$("main").append(div)
      }
    });
  };
}) 
// })











